A barrier is created by newbarrier() in an arena built by usinit(). The barrier is used by some fixed number (N) of processes. When each process is ready to rendezvous with the others, it issues barrier(N). As each process arrives at the barrier, it is suspended. When the Nth process calls barrier(), all the processes resume execution.
A barrier is the computing equivalent of N coworkers who agree to go to lunch together. When each person realizes it is lunch time, he or she goes to the lobby. When the Nth coworker reaches the lobby, all of them depart together for lunch. A barrier is very useful in initializing an application based on the Frame Scheduler (see "Preparing the System").
As an example of the use of a barrier, imagine that you discover that a nested loop to take the sum of a large matrix is a bottleneck in your program. To speed up the calculation you divide it between two processes. (Presumably they will run in different CPUs.) The first process is the one that requires the matrix sum, and which originally calculated the sum by itself. The second process is a new one, whose only purpose is to assist in the matrix sum calculation. You create a barrier named matsum to coordinate the two.
The logic of the second, helper, process is as follows: